package com.cjl.auth.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.cjl.auth.mapper.SysOperLogMapper;
import com.cjl.auth.service.SysDeptService;
import com.cjl.auth.service.SysOperLogService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cjl.model.system.SysOperLog;
import com.cjl.model.system.SysUser;
import com.cjl.vo.system.SysOperLogQueryVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import java.util.List;

/**
 * <p>
 * 操作日志记录 服务实现类
 * </p>
 *
 * @author cjl
 * @since 2023-03-20
 */
@Service
public class SysOperLogServiceImpl extends ServiceImpl<SysOperLogMapper, SysOperLog> implements SysOperLogService {
    @Override
    public IPage<SysOperLog> queryOperLog(SysOperLogQueryVo sysOperLogQueryVo, Page<SysOperLog> pageParam) {
        LambdaQueryWrapper<SysOperLog> wrapper = new LambdaQueryWrapper<>();
        String username = sysOperLogQueryVo.getOperName();
        String createTimeBegin = sysOperLogQueryVo.getCreateTimeBegin();
        String createTimeEnd = sysOperLogQueryVo.getCreateTimeEnd();
        if(!StringUtils.isEmpty(username)){
            wrapper.like(SysOperLog::getOperName, username);
        }
        if(!StringUtils.isEmpty(createTimeBegin)){
            wrapper.ge(SysOperLog::getOperTime, createTimeBegin);
        }
        if(!StringUtils.isEmpty(createTimeBegin)){
            wrapper.le(SysOperLog::getCreateTime, createTimeEnd);
        }
        Page<SysOperLog> sysUserPage = baseMapper.selectPage(pageParam, wrapper);

        return sysUserPage;
    }
}
